Release 10.1A: OpenEdge Development:
Programming Interfaces


Writing a ProDataSet definition to XML Schema files

Temp-table members of a ProDataSet can have a NAMESPACE-URI attribute that differs from the NAMESPACE-URI of the ProDataSet. In this case, the WRITE-XMLSCHEMA() method uses a separate XML Schema document for the temp-table definition, since the XML Schema TargetNamespace attribute is different.

In other words, suppose your ProDataSet has three temp-table buffers. The ProDataSet defines a default namespace. The first temp-table buffer does not define a default namespace, so it, therefore, uses the default namespace defined by its parent ProDataSet. The second temp-table buffer defines the same default namespace as the ProDataSet. So far, only a single XML Schema file is needed because only one namespace has been used. Suppose the third temp-table buffer defines a different default namespace. The method now needs to create a second XML Schema file for this temp-table buffer.

This code sample demonstrates the ability of the WRITE-XMLSCHEMA() method to write different XML Schema files for different namespaces:

Here is an abbreviated version of the include file that sets up the ProDataSet. Note the variety of namespaces used:

/* pi-tfx-writeSetup-2.i */ 
/* Define a ProDataSet and temp-table buffers that use multiple namespaces. */ 
DEFINE TEMP-TABLE ttDept NO-UNDO  
    NAMESPACE-URI "urn:Dept-Temp-Table" NAMESPACE-PREFIX "pfxDept"  
    /* Field definitions. */ 
DEFINE TEMP-TABLE ttEmp  NO-UNDO  
    NAMESPACE-URI "urn:Emp-Temp-Table"  NAMESPACE-PREFIX "pfxEmp"  
    /* Field definitions. */ 
DEFINE TEMP-TABLE ttFam NO-UNDO 
    NAMESPACE-URI "urn:Fam-Temp-Table" NAMESPACE-PREFIX "pfxFam"   
    /* Field definitions. */ 
DEFINE DATASET dsEmployees  
    NAMESPACE-URI "urn:PRODATASET" NAMESPACE-PREFIX "pfxDS" 
    /* ProDataSet definition. */ 
/* Populate ProDataSet. */ 

Here is the code. Note that only a single target file name is specified:

/* pi-tfx-write-2.p */ 
/* Write ProDataSet definition to XML Schema files. */ 
{pi-tfx-parameterVarDefs.i} 
{pi-tfx-writeSetup-2.i} 
ASSIGN 
     cTargetType = "FILE" 
     cFile = "prodataset.xsd"  
     lFormatted = YES 
     cEncoding = ? 
     lMinSchema = NO. 
returnValue = DATASET dsEmployees:WRITE-XMLSCHEMA(cTargetType, cFile, 
                                                  lFormatted, cEncoding, 
                                                  lMinSchema). 

This is the standard Open dialog box set up to show *.xsd files in the working directory:

The method call created four .xsd files. It used the specified file name as the main ProDataSet-level XML Schema file. It also used the name as a root for naming other .xsd files it needed to create for temp-table buffers with different namespaces.

When reading this XML Schema, an application would find the child XML schemas from the import directives in the in the main XML Schema. For example, here is a snippet of prodataset.xsd showing the imports:

<?xml version="1.0"?> 
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns="urn:PRODATASET" xmlns:pfxDS="urn:PRODATASET" 
    targetNamespace="urn:PRODATASET" elementFormDefault="qualified" 
    xmlns:prodata="urn:schemas-progress-com:xml-prodata:0001" 
    xmlns:pfxDept="urn:Dept-Temp-Table" xmlns:pfxEmp="urn:Emp-Temp-Table" 
    xmlns:pfxFam="urn:Fam-Temp-Table"> 
  <xsd:import namespace="urn:Dept-Temp-Table" 
      schemaLocation="prodataset_ttDept.xsd"/> 
  <xsd:import namespace="urn:Emp-Temp-Table" 
     schemaLocation="prodataset_ttEmp.xsd"/> 
  <xsd:import namespace="urn:Fam-Temp-Table" 
     schemaLocation="prodataset_ttFam.xsd"/> 
. 
. 
. 
</xsd:schema> 

Note: This feature works exclusively when writing XML Schema documents to operating system files (target-type “FILE”), otherwise it returns an error.


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095